#include "OS.h"
#include "ostype.h"
#include "Socket.h"
#include "Log.h"

int Socket::open(int domain,int type,int protocal,bool reuse_addr){
	this->setHandle(OS::socket(domain,type,protocal));
	if(this->getHandle() == INVALIDE_HANDLE){
		Log.error("Open Socket Failed ");
		return -1;
	}else{
		if(reuse_addr){
			int optv = 1;
			return OS::setsockopt(this->getHandle(),SOL_SOCKET,SO_REUSERADDR,&optv,sizeof(optv));
		}
	}
	return 1;
}
